package com.kinghunt.misp.common.enums.materialx;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * 操作类型枚举
 */
public enum MaterialTypeEnum {

    /**
     * 操作类型（1:出库、2:入库）
     */
    MATERIAL_TYPE_1(1, "出库"),
    MATERIAL_TYPE_2(2, "入库");

    @Getter
    private Integer value;
    @Getter
    private String desc;

    MaterialTypeEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    private final static Map<Integer, MaterialTypeEnum> map = new HashMap<>(8);
    static {
        for (MaterialTypeEnum e : MaterialTypeEnum.values()) {
            map.put(e.getValue(), e);
        }
    }

    public static MaterialTypeEnum getByType(Integer value) {
        if (Objects.isNull(value)) {
            return null;
        }
        return map.get(value);
    }
}
